﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Configuration
{
    /// <summary>
    /// 作用于属性，与xml文件中的节点匹配
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class XConfigAttribute : Attribute
    {
        /// <summary>
        /// xml节点名称
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// 默认值
        /// </summary>
        public object DefaultValue { get; private set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="name">配置xml时的节点名称</param>
        public XConfigAttribute(string name)
        {
            this.Name = name;
            this.DefaultValue = null;
        }

        /// <summary>
        /// 带默认值的构造函数
        /// </summary>
        /// <param name="name">配置xml时的节点名称</param>
        /// <param name="defaultValue">默认值，属性为复杂类型时可为null或为空</param>
        public XConfigAttribute(string name, object defaultValue)
        {
            this.Name = name;
            this.DefaultValue = defaultValue;
        }
    }
}
